@extends('default.layouts.personalPublic')
@section('title', '简历投递记录')
@section('headcss')
    @parent
    <link rel="stylesheet" href="{{asset('/default/css/personal/resumeList.css')}}">
@endsection
@section('rightcon')
    <div class="right">

        <!--简历投递记录-->
        <div class="jright">
            <div class="content">
                <div class="jobtitle">
                    <div class="tithead">
                        <h2>简历投递记录</h2>
                    </div>
                </div>
                {{--\搜索内容--}}
                <div class="jobsearch">
                    <form name="Formso" action="{{url('personal/resume_send')}}" method="post">
                        {{csrf_field()}}
                        <span><input name="keyword" class="keyword" value="" id="keyword" placeholder="请输入公司名称或者职位名称" type="text"/></span>
                         <span><input name="submit" class="searpos" value="" id="" type="submit"/></span>
                    </form>
                </div>

                {{--显示列表--}}
                <div class="pinfo">
                    <form name="thisForm" action="{{url('personal/resume_send')}}" method="post">
                        {{csrf_field()}}
                        <div class="listmenu">
                                <ul class="one">
                                    <li class="p1"><input name="selected_id[]" class="checkboxs" value="234" type="checkbox"/></li>
                                    <li class="p4">投递时间</li>
                                    <li class="p2">职位名称</li>
                                    <li class="p3">
                                        <div class="status">
                                            <input id="job_status" name="job_status" type="hidden" value="{{$job_status}}">
                                            <div id="job_status_select" class="select" style="width:136px; height:28px; line-height: 28px;">
                                                <span><a></a></span><i></i>
                                            </div>
                                        </div>
                                    </li>
                                    <li class="p6">详细信息</li>
                                    <li class="p5">撤销投递</li>
                                </ul>
                            <div class="information"><span>共收到<em>{{$resume_send->total()}}</em>条简历投递记录！</span></div>
                            {{--循环--}}
                            @if($resume_send->count() > 0 )
                                @foreach($resume_send as $v)
                                    <div id="list{{$v->id}}" class="slist">
                                        <ul>
                                            <li class="p1">
                                                <input name="selected_id[]" class="checkboxs" value="{{$v->id}}" type="checkbox"/>
                                            </li>
                                            <li class="p4">{{$v->created_at}}</li>
                                            <li class="p2">
                                                <span class="jpost"><a href="{{url('jobinfo_'.idEncryption($v->job_id).'.html')}}" target="_blank">{{$v->job_title}}</a></span>
                                                <span class="jcompany"><a class="company" href="{{url('comabout_'.idEncryption($v->com_id).'.html')}}" target="_blank">{{$v->company_name}}</a></span>
                                            </li>
                                            <li class="p3">
                                                @if($v->status != '3' && $v->status != '0' )
                                                    <span class="statusval">{{$v->statusval}}</span>
                                                @else
                                                    <span class="statusval declined">{{$v->statusval}}</span>
                                                @endif
                                            </li>
                                            <li class="p6"><a class="details">展开详情</a></li>
                                            <li class="p5"><i class="revoked"></i></li>
                                        </ul>
                                    </div>
                                @endforeach
                            @else
                                <div class="nullcon">对不起！没有符合条件的记录！</div>
                            @endif
                            <ul class="one last">
                                <li class="p1" style="width:80px;">
                                    <input name="selectall" id="selectall" class="checkboxs" value="234" type="checkbox" onclick="CheckAll(this)"/>
                                    <label for="selectall">全选</label>
                                </li>
                                <li class="p2"><span class="pborder" onclick="showconfirm('{{url('personal/post_del')}}','1')">删除记录</span></li>
                            </ul>
                        </div>
                    </form>
                </div>
                {{--分页--}}
                <div class="page_list" style="width: 100%; float: left; margin-top:15px;">
                    {!! $resume_send->appends($appends)->links() !!}
                </div>
            </div>
        </div>
    </div>
@endsection
@section('footerjs')
    @parent
    <script>
        $('#resume_send').addClass('on');
        $(function(){
            var status = [
                {"value":'',"text":"不限"},
                {"value":0,"text":"未处理"},
                {"value":1,"text":"HR已查看"},
                {"value":2,"text":"同意邀约"},
                {"value":3,"text":"婉拒邀约"}
            ];
            var listmenu = $('.right').find('.pinfo').find('.listmenu');
            listmenu.find("#job_status").select({
                optionData: status,
                selected:'{{$job_status}}',
                callback:function(val,text){
                    document.thisForm.submit();
                }
            });
            //撤销投递
            @if($resume_send->count() > 0 )
                @foreach($resume_send as $v)
                    listmenu.find("#list" + '{{$v->id}}').find('i.revoked').click(function(){
                        layer.confirm('您确定要撤销这个投递吗？', {
                            btn: ['确定', '取消'] //按钮
                        }, function () {
                            $.post("/personal/post_undo",{'id':'{{$v->id}}','_token':"{{csrf_token()}}"},function (data) {
                                if(data.status==0){
                                    listmenu.find("#list" + '{{$v->id}}').remove();
                                    layer.msg(data.msg, {icon: 6,time:1500});
                                }else{
                                    layer.msg(data.msg, {icon: 5,time:1500});
                                }
                            });
                        });
                    });
                @endforeach
            @endif

            {{--展开详情--}}
            @if($resume_send->count() > 0 )
                @foreach($resume_send as $v)
                    $('#list{{$v->id}}').find('ul li').find('a.details').click(function(){
                        var othis = $(this);
                        var updated_at = '{{ $v->updated_at}}';
                        var post_status = '{{ $v->status}}';
                        if(othis.parents('.slist').find('.resumeInfo').length <= 0){
                            //加载当前信息
                            $.ajax({
                                url: '/personal/post_info',
                                dataType: "json",
                                data: {
                                    job_id:'{{ $v->job_id}}',
                                    com_id: '{{ $v->com_id}}',
                                    _token: "{{csrf_token()}}"
                                },
                                type: "POST",
                                success: function (data) {
                                    var str = '';
                                    str += '<div class="resumeInfo">';
                                    str += '<div class="line"></div>';
                                    str += '<ul>';
                                    //谁浏览了我
                                    if(data.status == '1'){
                                        str += '<li><em>▪</em><span class="time">'+data.browse_resume.updated_at+'</span><p>HR对您的简历进行了查看</p></li>';
                                    }
                                    //投递状态
                                    if(post_status == '2'){
                                        str += '<li><em>▪</em><span class="time">'+updated_at+'</span><p>HR认为您的履历和职位合适,同意邀请您面试</p></li>';
                                    }else if(post_status == '3'){
                                        str += '<li><em>▪</em><span class="time">'+updated_at+'</span><p>HR认为您的履历和职位不合适,已拒绝了您的职位申请</p></li>';
                                    }
                                    //面试通知
                                    if(data.interview_status == '1'){
                                        str += '<li><em>▪</em><span class="time">'+updated_at+'</span><p>请您于<span>'+data.interview.interview_time+'</span>到' +
                                                '<span>'+data.interview.region+'</span>参加面试。联系电话:<span>'+data.interview.phone+'</span>，' +
                                                '联系人:<span>'+data.interview.contacts+'</span></p></li>';
                                    }
                                    if(data.status == '0' && post_status == '0' && data.interview_status == '0'){
                                        str += '<li><em>▪</em><p>暂无查看记录</p></li>';
                                    }
                                    str += '</ul>';
                                    str += '</div>';
                                    othis.parents('ul').after(str);
                                    $('.listmenu').find('.resumeInfo').hide();
                                    $('.listmenu').find('ul').removeClass('list');
                                    othis.parents('ul').addClass('list');
                                    othis.parents('.slist').find('.resumeInfo').show();
                                },
                                error: function () {
                                    layer.msg('可能网络原因引起的错误',{time:1500});
                                }
                            });
                        }else{
                            if(othis.parents('.slist').find('.resumeInfo').is(":hidden")){
                                $('.listmenu').find('.resumeInfo').hide();
                                $('.listmenu').find('ul').removeClass('list');
                                othis.parents('ul').addClass('list');
                                othis.parents('.slist').find('.resumeInfo').show();
                            }else{
                                othis.parents('ul').removeClass('list');
                                othis.parents('.slist').find('.resumeInfo').hide();
                            }
                        }
                    });
                @endforeach
            @endif
        });
    </script>
    <script type="text/javascript" src="{{asset('/default/js/personal/resumeList.js')}}"></script>
@endsection